//
//  QLOrderCommentCell.m
//  神约
//
//  Created by qlwl on 17/2/22.
//  Copyright © 2017年 qlwl. All rights reserved.
//

#import "QLOrderCommentCell.h"
#import "UIView+FrameKIt.h"

#define InteritemNum 3
#define InteritemSpace 12
#define LineSpace 8
#define CellWidth (iphoneWidth - 20 - (InteritemNum - 1)*InteritemSpace)/InteritemNum
#define CellHeight 40

@implementation QLCommentGoodTypeCell
- (void) setGoodTypeArray:(NSArray *)goodTypeArray
{
    _goodTypeArray = goodTypeArray;
    ((UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout).minimumLineSpacing = LineSpace;
    ((UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout).minimumInteritemSpacing = InteritemSpace;
    [self.collectionView reloadData];
    
    int itemCount = (int)_goodTypeArray.count;
    int lineNum = itemCount%InteritemNum == 0?itemCount/InteritemNum:itemCount/InteritemNum+1;
    float cellHeight = 2*8 + (lineNum - 1)*LineSpace + lineNum*CellHeight;
    self.f_height = cellHeight;
}

#pragma mark CollectionViewDelegate
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return _goodTypeArray.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"commentGoodTypeCollCell" forIndexPath:indexPath];
    UIButton * btn = [cell viewWithTag:10];
    return cell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(CellWidth, CellHeight);
    
}
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    return UIEdgeInsetsMake(0,0,0,0);
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    
}
- (BOOL) shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender
{
    return YES;
}



@end

@implementation QLCommentUserInfoCell

@end

@implementation QLOrderCommentCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
